package object;

import java.util.Arrays;

public class StringTest01 {
    public static void main(String[] args) {
        //String的三种正定表达式方法
        //Matches()
        /*
        邮箱正则表达式:
            [a-zA-Z0-9_]+@[a-zA-Z0-9]+(\.[a-zA-Z]+)+
         */
        String email = "wangxy@qq.com";
        String regex = "[a-zA-Z0-9_]+@[a-zA-Z0-9]+(\\.[a-zA-Z]+)+";
        boolean match = email.matches(regex);
        if (match){
            System.out.println("是正确的邮箱格式");
        }else {
            System.out.println("不是正确的邮箱格式");
        }
        //ReplaceAll()
        String line = "www123xxx456yyy789";
        line = line.replaceAll("[0-9]+","#NUMBER#");
        System.out.println(line);
        //Split()
        String line1 = "www123xxx456yyy789";
        String[] data = line1.split("[0-9]+");//按数字拆分(数字就拆没了)
        System.out.println(Arrays.toString(data));//将data数组转换为字符串并输出
    }
}
